home *** CD-ROM | disk | FTP | other *** search
/ Sprite 1984 - 1993 / Sprite 1984 - 1993.iso / lib / tclX-6.4 / help / intro / keyedlists < prev    next >
Encoding:
Text File  |  1992-12-17  |  1.8 KB  |  46 lines

  1.  
  2.  
  3.      KEYED LISTS
  4.           Extended Tcl defines a special type of list referred to as
  5.           keyed lists.  These lists provided a structured data type
  6.           built upon standard Tcl lists.  This provides a
  7.           functionality similar to structs in the C programming
  8.           language.
  9.  
  10.           A keyed list is a list in which each element contains a key
  11.           and value pair.  These element pairs are stored as lists
  12.           themselves, where the key is the first element of the list,
  13.           and the value is the second.  The key-value pairs are
  14.           refered to as fields.  This is an example of a keyed list:
  15.  
  16.                    {{NAME {Frank Zappa}} {JOB {musician and
  17.                composer}}}
  18.  
  19.           If the variable person contained the above list, then
  20.           keylget person NAME would return {Frank Zappa}.  Executing
  21.           the command:
  22.  
  23.                keylset person ID 106
  24.  
  25.           would make person contain
  26.  
  27.                    {{ID 106} {NAME {Frank Zappa}} {JOB {musician and
  28.                composer}}
  29.  
  30.           Fields may contain subfields; `.' is the seperator
  31.           character.  Subfields are actually fields where the value is
  32.           another keyed list.  Thus the following list has the top
  33.           level fields ID and NAME, and subfields NAME.FIRST and
  34.           NAME.LAST:
  35.  
  36.                    {ID 106} {NAME {{FIRST Frank} {LAST Zappa}}}
  37.  
  38.           There is no limit to the recursive depth of subfields,
  39.           allowing one to build complex data structures.
  40.  
  41.           Keyed lists are constructed and accessed via a number of
  42.           commands.  All keyed list management commands take the name
  43.           of the variable containing the keyed list as an argument
  44.           (i.e. passed by reference), rather than passing the list
  45.           directly.
  46.